<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:74:"F:\PHPwork\w_blog\public/../application/admin/view/auth_rule/menulist.html";i:1496727317;}*/ ?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__STATIC__/js/lib/html5shiv.js"></script>
    <script type="text/javascript" src="__STATIC__/js/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/js/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>菜单管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 菜单管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="text-c">
        <input type="text" name="search" id="search" onkeyup="" placeholder="菜单名称" style="width:250px" class="input-text">
        <button type="submit" class="btn btn-success radius" id="" name="" onclick="search()"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
        <a href="javascript:;" class="btn btn-primary radius" onclick="add_pmenu()"><i class="Hui-iconfont">&#xe600;</i> 添加顶级菜单</a>
        <a href="javascript:;"  class="btn btn-primary radius" onclick="add_menu()"><i class="Hui-iconfont">&#xe600;</i> 添加菜单</a>
        </span>
    <div class="mt-20">
        <table id="datatable"  class="table table-border table-bordered table-hover table-bg table-sort" >
            <thead>
            <tr class="text-c">
                <th width="80">ID</th>
                <th width="100">顶级菜单名称</th>
                <th width="100">子菜单名称</th>
                <th width="100">地址</th>
                <th width="100">操作</th>
            </tr>
            </thead>
        </table>
    </div>
</div>
</div>

<script type="text/javascript" src="__STATIC__/js/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/js/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="__STATIC__/css/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="__STATIC__/css/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="__STATIC__/js/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/js/lib/datatables/1.10.11/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__STATIC__/js/lib/laypage/1.2/laypage.js"></script>
<style type="text/css">
    #datatable tr td{
        text-align: center;
    }
</style>
<script type="text/javascript">
    $(document).ready(function() {
        datatable = $("#datatable").dataTable({
            /*基本参数设置，以下参数设置和默认效果一致*/
            "bPaginate": true, //翻页功能
            "bLengthChange": false, //改变每页显示数据数量
            "bFilter": false, //过滤功能
            "bSort": true, //排序功能
            "bInfo": true,//页脚信息
            "processing": true,
            "serverSide": true,
            "ajax" : "<?php echo url('admin/auth_rule/menuList'); ?>",
            "columns": [
                {"data": "id"},
                {"data": "f_name"},
                {"data": "name"},
                {"data": "href"},
                {"data": ""}
            ],
            "columnDefs": [
                {
                    "targets": [4],
                    "data": "id",
                    "render": function(data, type, row,meta) {
                         if(row.pid>0) {
                             var str = "<a href='javascript:;'  class='btn btn-success radius' onclick='edit_menu(" + row.id + ")'>编辑</a>"
                         }else {
                             var str = "<a href='javascript:;'  class='btn btn-success radius' onclick='edit_pmenu(" + row.id + ")'>编辑</a>"
                         }
                         str=str+"&nbsp;<a href='javascript:;'  class='btn btn-danger radius' onclick='del_menu("+row.id+")'>删除</a>"
                        return str;
                    }
                }
            ],
            "oLanguage": {
                "sProcessing" : "数据加载中，请稍后...",
                "sLengthMenu" : "显示 _MENU_ 条",
                "sZeroRecords" : "没有您要搜索的内容",
                "sInfo" : "从 _START_ 到  _END_ 条记录 总记录数为 _TOTAL_ 条",
                "sInfoEmpty" : "记录数为0",
                "sInfoFiltered" : "(全部记录数 _MAX_ 条)",
                "sInfoPostFix" : "",
                "sSearch" : "搜索",
                "sUrl" : "",
                "oPaginate": {
                    "sFirst" : "第一页",
                    "sPrevious" : "上一页",
                    "sNext" : "下一页",
                    "sLast" : "最后一页"
                }
            },
            "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
                oSettings.jqXHR = $.ajax( {
                    "dataType": 'json',
                    "type": "POST",
                    "url":"<?php echo url('admin/auth_rule/menuList'); ?>",
                    "data": {
                        "search":$("#search").val(),
                        "data":aoData
                    },
                    "success": fnCallback
                });
            }
        });
    });
    //搜索
    function search(){
        datatable.fnDraw();
    }
    //删除菜单
    function del_menu(id){
        layer.confirm("是否删除？",{
            btn:["是","否"]
        },function(){
            $.ajax({
                type:"POST",
                url:"<?php echo url('admin/auth_rule/delmenu'); ?>",
                data:{id:id},
                dataType:"json",
                success:function(data){
                    if(data.code==1){
                        layer.msg(data.msg,{icon:1,title:"系统提示",time:1000},function(){
                            datatable.fnDraw(false);
                        });
                    }else {
                        layer.msg(data.msg,{icon:1,title:"系统提示",time:1000});
                    }
                }
            })
        },function(){
            layer.close();
        })
    }
    //添加顶级菜单页面
    function add_pmenu(){
         var index=layer.open({
             type:2,
             area:['450px','200px'],
             title:"添加顶级菜单",
             content:"<?php echo url('admin/auth_rule/addPmenu'); ?>"
         });
    }
    //添加菜单
    function add_menu(){
        var index=layer.open({
            type:2,
            area:['550px','300px'],
            title:"添加菜单",
            content:"<?php echo url('admin/auth_rule/addMenu'); ?>"
        });
    }
    //编辑顶级菜单
    function edit_pmenu(id){
        var index=layer.open({
            type:2,
            area:['450px','200px'],
            title:"编辑顶级菜单",
            content:"<?php echo url('admin/auth_rule/editPmenu'); ?>?id="+id+""
        });
    }
    //编辑子菜单
    function edit_menu(id){
        var index=layer.open({
            type:2,
            area:['550px','300px'],
            title:"编辑菜单",
            content:"<?php echo url('admin/auth_rule/editMenu'); ?>?id="+id+""
        });
    }
</script>

</body>
</html>